<?php
/**
 * Cellphonezone Commercial Extension
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Cellphonezone Commercial Extension License
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://store.delorumcommerce.com/license/commercial-extension
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tinybrick.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade this package to newer
 * versions in the future. 
 *
 * @category   Cellphonezone
 * @package    Cellphonezone_Repay
 * @copyright  Copyright (c) 2010 Cellphonezone Inc. LLC
 * @license    http://store.delorumcommerce.com/license/commercial-extension
 */
class Cellphonezone_Repay_Model_Order_Address_Total_Subtotal extends Cellphonezone_Repay_Model_Order_Address_Total_Abstract
{
    /**
     * Collect address subtotal
     *
     * @param   Mage_Sales_Model_Order_Address $address
     * @return  Mage_Sales_Model_Order_Address_Total_Subtotal
     */
    public function collect(Cellphonezone_Repay_Model_Order_Address $address)
    {
    	
        /**
         * Reset subtotal information
         */
        $address->setSubtotal(0);
        $address->setBaseSubtotal(0);
        $address->setGrandTotal(0);
        $address->setBaseGrandTotal(0);
        
        
        
		$order = $address->getOrder();		
		$address->setSubtotal($order->getSubtotal());
		$address->setBaseSubtotal($order->getBaseSubtotal());
        /**
         * Initialize grand totals
         */ 
        $address->setGrandTotal($address->getSubtotal());
        $address->setBaseGrandTotal($address->getBaseSubtotal());
        return $this;
    }
  
    public function fetch(Cellphonezone_Repay_Model_Order_Address $address)
    {	
        $address->addTotal(array(
            'code'=>$this->getCode(),
            'title'=>Mage::helper('sales')->__('Subtotal'),
            'value'=>$address->getSubtotal()
        ));
        return $this;
    }
	
	 /**
     * Get Subtotal label
     *
     * @return string
     */
    public function getLabel()
    {
        return Mage::helper('sales')->__('Subtotal');
    }
}